package xml;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class XMLWriter {
	private Element root;
	public XMLWriter(String rootName) throws ParserConfigurationException{
		//We need a Document
        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
        Document doc = docBuilder.newDocument();

        //create the root element and add it to the document
        root = doc.createElement(rootName);
        doc.appendChild(root);
	}
	public void addToRoot(Element element){
		root.appendChild(element);
	}
}
